<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>bit_stream - ClueLib</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/prettify.js"></script></head><body class="FramedContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.52 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="bit_stream"></a>bit_stream</h1><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>virtual class bit_stream #(</td><td class="PType  prettyprint " nowrap>type&nbsp;</td><td class="PParameter  prettyprint " nowrap>T</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> bit</td><td class="PAfterParameters  prettyprint "nowrap>) extends data_stream #( T, 1 )</td></tr></table></td></tr></table></blockquote><p>A parameterized class that manages a bit stream.</p><h4 class=CHeading>Parameter</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>T</td><td class=CDLDescription><span class="optional">optional</span> The type of the bit stream.&nbsp; The <b>T</b> must be the single bit data types (<b>bit</b>, <b>logic</b>, or <b>reg</b>).&nbsp; The default type is <b>bit</b>.</td></tr></table><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#bit_stream" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">bit_stream</a></td><td class=SDescription>A parameterized class that manages a bit stream.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#bit_stream.Types" >Types</a></td><td class=SDescription></td></tr><tr class="SType SIndent2 SMarked"><td class=SEntry><a href="#bit_stream.bs_type" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">bs_type</a></td><td class=SDescription>The bit stream type. </td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#bit_stream.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#bit_stream.alternate" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">alternate</a></td><td class=SDescription><span class="static">static</span> Returns a new bit stream with the elements whose values alternate between 0 and 1.</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#bit_stream.count_zeros" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">count_zeros</a></td><td class=SDescription><span class="static">static</span> Counts the number of bit-stream items having value 0.</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#bit_stream.count_ones" id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">count_ones</a></td><td class=SDescription><span class="static">static</span> Counts the number of bit-stream items having value 1.</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#bit_stream.count_unknowns" id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">count_unknowns</a></td><td class=SDescription><span class="static">static</span> Counts the number of bit-stream items having value X.</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#bit_stream.count_hizs" id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">count_hizs</a></td><td class=SDescription><span class="static">static</span> Counts the number of bit-stream items having value Z.</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="bit_stream.Types"></a>Types</h3></div></div>

<div class="CType"><div class=CTopic><h3 class=CTitle><a name="bit_stream.bs_type"></a>bs_type</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">typedef T bs_type[]</td></tr></table></blockquote><p>The bit stream type.&nbsp; The shorthand of the dynamic array of type <b>T</b>.</p></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="bit_stream.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="bit_stream.alternate"></a>alternate</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function bs_type alternate(</td><td class="PTypePrefix  prettyprint " nowrap>int&nbsp;</td><td class="PType  prettyprint " nowrap>unsigned&nbsp;</td><td class="PParameter  prettyprint " nowrap>length,</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%></td></tr><tr><td></td><td class="PTypePrefix  prettyprint " nowrap></td><td class="PType  prettyprint " nowrap>T&nbsp;</td><td class="PParameter  prettyprint " nowrap>init_value</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PTypePrefix  prettyprint " nowrap></td><td class="PType  prettyprint " nowrap>bit&nbsp;</td><td class="PParameter  prettyprint " nowrap>randomize_init_value</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><span class="static">static</span> Returns a new bit stream with the elements whose values alternate between 0 and 1.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>length</td><td class=CDLDescription>The length of the output bit stream.</td></tr><tr><td class=CDLEntry>init_value</td><td class=CDLDescription><span class="optional">optional</span> The value of the first element (0 or 1).&nbsp; The default is 0.</td></tr><tr><td class=CDLEntry>randomize_init_value</td><td class=CDLDescription><span class="optional">optional</span> If 1, the value of the first element is randomized (the <b>init_value</b> argument is ignored).&nbsp; The default is 0.</td></tr></table><h4 class=CHeading>Returns</h4><p>A <u>new</u> bit stream with the elements whose values alternate between 0 and 1.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">bit expected[] = new[8]( '{ 1, 0, 1, 0, 1, 0, 1, 0 } );
assert( bit_stream#(bit)::alternate( 8, .init_value( 1 ) ) == expected );</pre></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="bit_stream.count_zeros"></a>count_zeros</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_zeros(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><span class="static">static</span> Counts the number of bit-stream items having value 0.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>bs</td><td class=CDLDescription>A bit stream.</td></tr></table><h4 class=CHeading>Returns</h4><p>The number of items having value 0.&nbsp; If the type <b>T</b> is not a single-bit data type, -1 is returned.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">bit bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1 } );
assert( bit_stream#(bit)::count_zeros( bs ) == 8 );</pre></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="bit_stream.count_ones"></a>count_ones</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_ones(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><span class="static">static</span> Counts the number of bit-stream items having value 1.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>bs</td><td class=CDLDescription>A bit stream.</td></tr></table><h4 class=CHeading>Returns</h4><p>The number of items having value 1.&nbsp; If the type <b>T</b> is not a single-bit data type, -1 is returned.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">bit bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1 } );
assert( bit_stream#(bit)::count_ones( bs ) == 8 );</pre></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="bit_stream.count_unknowns"></a>count_unknowns</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_unknowns(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><span class="static">static</span> Counts the number of bit-stream items having value X.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>bs</td><td class=CDLDescription>A bit stream.</td></tr></table><h4 class=CHeading>Returns</h4><p>The number of items having value X.&nbsp; If the type <b>T</b> is not a single-bit data type, -1 is returned.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">logic bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 'x, 'x, 'x, 'x, 'z, 'z, 'z, 'z } );
assert( bit_stream#(logic)::count_unknowns( bs ) == 4 );</pre></blockquote></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="bit_stream.count_hizs"></a>count_hizs</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_hizs(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><p><span class="static">static</span> Counts the number of bit-stream items having value Z.</p><h4 class=CHeading>Argument</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>bs</td><td class=CDLDescription>A bit stream.</td></tr></table><h4 class=CHeading>Returns</h4><p>The number of items having value Z.&nbsp; If the type <b>T</b> is not a single-bit data type, -1 is returned.</p><h4 class=CHeading>Example</h4><blockquote><pre class="prettyprint">logic bs[] = new[16]( '{ 0, 0, 0, 0, 1, 1, 1, 1, 'x, 'x, 'x, 'x, 'z, 'z, 'z, 'z } );
assert( bit_stream#(logic)::count_hizs( bs ) == 4 );</pre></blockquote></div></div></div>

</div><!--Content-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CClass><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>virtual class bit_stream #(</td><td class="PType  prettyprint " nowrap>type&nbsp;</td><td class="PParameter  prettyprint " nowrap>T</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> bit</td><td class="PAfterParameters  prettyprint "nowrap>) extends data_stream #( T, 1 )</td></tr></table></td></tr></table></blockquote>A parameterized class that manages a bit stream.</div></div><div class=CToolTip id="tt2"><div class=CType><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">typedef T bs_type[]</td></tr></table></blockquote>The bit stream type. </div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function bs_type alternate(</td><td class="PTypePrefix  prettyprint " nowrap>int&nbsp;</td><td class="PType  prettyprint " nowrap>unsigned&nbsp;</td><td class="PParameter  prettyprint " nowrap>length,</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%></td></tr><tr><td></td><td class="PTypePrefix  prettyprint " nowrap></td><td class="PType  prettyprint " nowrap>T&nbsp;</td><td class="PParameter  prettyprint " nowrap>init_value</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0,</td></tr><tr><td></td><td class="PTypePrefix  prettyprint " nowrap></td><td class="PType  prettyprint " nowrap>bit&nbsp;</td><td class="PParameter  prettyprint " nowrap>randomize_init_value</td><td class="PDefaultValuePrefix  prettyprint ">&nbsp;=&nbsp;</td><td class="PDefaultValue  prettyprint " width=100%> 0</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><span class="static">static</span> Returns a new bit stream with the elements whose values alternate between 0 and 1.</div></div><div class=CToolTip id="tt4"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_zeros(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><span class="static">static</span> Counts the number of bit-stream items having value 0.</div></div><div class=CToolTip id="tt5"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_ones(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><span class="static">static</span> Counts the number of bit-stream items having value 1.</div></div><div class=CToolTip id="tt6"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_unknowns(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><span class="static">static</span> Counts the number of bit-stream items having value X.</div></div><div class=CToolTip id="tt7"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>static function int count_hizs(</td><td class="PType  prettyprint " nowrap>bs_type&nbsp;</td><td class="PParameter  prettyprint " nowrap>bs</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><span class="static">static</span> Counts the number of bit-stream items having value Z.</div></div><!--END_ND_TOOLTIPS-->

<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>